const initState = {
  id: "",
  nickname: "",
  avator: "",
  token: "",
};

const reducer = (state = initState, action: any) => {
  switch (action.type) {
    case "loginSuccess": {
      return {
        ...state,
        id: action.payload.id as string,
        nickname: action.payload.nickname as string,
        avator: action.payload.avator as string,
        token: action.payload.token as string,
      };
    }
    case "setAvator": {
      return {
        ...state,
        avator: action.payload as string,
      };
    }
  }
  return state;
};

export default reducer;
